package Practices;

public class pra_word {
    public static void main(String[] args) {
        String str = "this my friend",s = ""; //取得最后一个单词
        char ca = ' ';
        for (int i = str.length()-1; i >= 0; i--) {  //倒着遍历
            if (str.charAt(i) == ca) {  //判断空格
                break;
            } else {
                s = str.charAt(i) + s;
            }
        }
        System.out.println(s);
        System.out.println(s.length());
    }
}
